package com.sky.mapper.admin;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.pojo.Orders;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface OrderMapper {
    /**
     * 分页查询
     * @param dto
     * @return
     */
    Page<OrderVO> search(OrdersPageQueryDTO dto);

    /**
     * 根据订单状态统计数量
     * @param toBeConfirmed
     * @return
     */
    @Select("select count(id) from orders where status = #{status} " )
    Integer countStatus(Integer toBeConfirmed);

    /**
     * 根据订单id查询订单信息
     * @param orderId
     * @return
     */
    OrderVO getByOrderId(Long orderId);

    /**
     * 获取订单信息
     * @param id
     * @return
     */
    Orders getOrders(Long id);

    /**
     * 取消订单
     * @param
     */
    @Update("update orders set status=#{status} where number=#{number}")
    void cancelOrder(@Param("status") Integer status,
                     @Param("number") String number);


    void update(Orders orders);
}
